﻿using System;
using System.Collections;

namespace InfoClasses
{
/// <summary>
/// Base abstract class for storage user info
/// </summary>

public abstract class Info
{
    protected string _workTable;
    public string WorkTable
    {
        get { return _workTable; }
    }

    public ArrayList _collumnNames = new ArrayList();

    protected string _firstName;
    protected string _middleName;
    protected string _lastName;
    protected string _pasportID;

    public string FirstName
    {
        get { return _firstName; }
    }

    public string MiddleName
    {
        get { return _middleName; }
    }

    public string LastName
    {
        get { return _lastName; }
    }

    public string PasportID
    {
        get { return _pasportID; }
    }

    protected string _touristID;
    protected string _country;
    protected string _startOfTour;
    protected string _endOfTour;

    public string TouristID
    {
        get { return _touristID; }
    }

    public string Country
    {
        get { return _country; }
    }

    public string StartOfTour
    {
        get { return _startOfTour; }
    }

    public string EndOfTour
    {
        get { return _endOfTour; }
    }

    public abstract void ReadInfo();
    public abstract void ShowInfo();
    public abstract void FixInfo();
}

/// <summary>
/// Class for storage and manipulation with user info for table "Tourist"
/// </summary>

public class TouristsInfo : Info
{
    private bool _mark = false;
    ConsoleKeyInfo _key = new ConsoleKeyInfo();

    public TouristsInfo()
    {
        _workTable = "Tourists";
    }

    /// <summary>
    /// Show readed user info
    /// </summary>

    public override void ShowInfo()
    {
        string line1 = String.Format("\n{0,-15}{1,-15}{2,-15}{3,-15}", "First name",
            "Middle name", "Last name", "pasportID");
        string line2 = String.Format("{0,-15}{1,-15}{2,-15}{3,-15}", _firstName,
            _middleName, _lastName, _pasportID);
        Console.WriteLine(line1);
        Console.WriteLine(line2);
    }

    /// <summary>
    /// Raplace old user info by newer
    /// </summary>

    public override void FixInfo()
    {

        while (_mark == false)
        {
            Console.WriteLine("\nSelect the field you want to fix and press proper key" +
                "\nFirst name - 1, Middle name - 2, Last name - 3, pasportID - 4, End fix - 5\n");
        M: _key = Console.ReadKey(true);

            switch (_key.Key)
            {
                case ConsoleKey.D1:
                    {
                        Console.WriteLine("\nEnter new Firs name (no more than 20 characters) ");
                        _firstName = Console.ReadLine();
                        break;
                    }
                case ConsoleKey.D2:
                    {
                        Console.WriteLine("\nEnter new Middle name (no more than 20 characters) ");
                        _middleName = Console.ReadLine();
                        break;
                    }
                case ConsoleKey.D3:
                    {
                        Console.WriteLine("\nEnter new Last name (no more than 20 characters) ");
                        _lastName = Console.ReadLine();
                        break;
                    }
                case ConsoleKey.D4:
                    {
                        Console.WriteLine("\nEnter new pasport ID (no more than 10 characters) ");
                        _pasportID = Console.ReadLine();
                        break;
                    }
                case ConsoleKey.D5:
                    {
                        _mark = true;
                        break;
                    }
                default:
                    {
                        Console.WriteLine("\n Program can not recognize the comand, try again!");
                        goto M;
                    }
            }
        }

    }

    /// <summary>
    /// Read user input info
    /// </summary>

    public override void ReadInfo()
    {
        Console.WriteLine("\nPlease enter your data\n" +
            "Enter Firs name (no more than 20 characters) ");
        _firstName = Console.ReadLine();
        Console.WriteLine("Enter Middle name (no more than 20 characters)");
        _middleName = Console.ReadLine();
        Console.WriteLine("Enter Last name (no more than 20 characters)");
        _lastName = Console.ReadLine();
        Console.WriteLine("Enter pasport ID (no more than 10 characters)");
        _pasportID = Console.ReadLine();
    }

}

/// <summary>
/// Class for storage and manipulation with user info for table "Tours"
/// </summary>

public class ToursInfo : Info
{
    private bool _mark = false;
    ConsoleKeyInfo _key = new ConsoleKeyInfo();

    public ToursInfo()
    {
        _workTable = "Tours";
    }

    /// <summary>
    /// Show readed user info
    /// </summary>

    public override void ShowInfo()
    {
        string line1 = String.Format("\n{0,-15}{1,-15}{2,-15}{3,-15}", "TouristID",
            "Country", "StartOfTour", "EndOfTour");
        string line2 = String.Format("{0,-15}{1,-15}{2,-15}{3,-15}", _touristID,
            _country, _startOfTour, _endOfTour);
        Console.WriteLine(line1);
        Console.WriteLine(line2);
    }

    /// <summary>
    /// Raplece old user info by newer
    /// </summary>

    public override void FixInfo()
    {
        while (_mark == false)
        {
            Console.WriteLine("Select the field you want to fix and press proper key" +
                "\nTouristID - 1, Country - 2, StartOfTour - 3, EndOfTour - 4, End fix - 5\n");
        M: _key = Console.ReadKey(true);

            switch (_key.Key)
            {
                case ConsoleKey.D1:
                    {
                        Console.WriteLine("\nEnter new TouristID ");
                        _touristID = Console.ReadLine();
                        break;
                    }
                case ConsoleKey.D2:
                    {
                        Console.WriteLine("\nEnter new Country (no more than 20 characters) ");
                        _country = Console.ReadLine();
                        break;
                    }
                case ConsoleKey.D3:
                    {
                        Console.WriteLine("\nEnter new start of tour date (in format mm.dd.yyyy) ");
                        _startOfTour = Console.ReadLine();
                        break;
                    }
                case ConsoleKey.D4:
                    {
                        Console.WriteLine("\nEnter new end of tour date (in format mm.dd.yyyy) ");
                        _endOfTour = Console.ReadLine();
                        break;
                    }
                case ConsoleKey.D5:
                    {
                        _mark = true;
                        break;
                    }
                default:
                    {
                        Console.WriteLine("\n Program can not recognize the comand, try again!");
                        goto M;
                    }
            }
        }

    }

    /// <summary>
    /// Read user input info
    /// </summary>

    public override void ReadInfo()
    {
        Console.WriteLine("\nPlease enter your data\n" +
            "Enter TouristID ");
        _touristID = Console.ReadLine();
        Console.WriteLine("Enter Country (no more than 20 characters)");
        _country = Console.ReadLine();
        Console.WriteLine("Enter start of tour datein format mm.dd.yyyy)");
        _startOfTour = Console.ReadLine();
        Console.WriteLine("Enter end of tour date(in format mm.dd.yyyy)");
        _endOfTour = Console.ReadLine();
    }
}
}
